'use strict';

angular.module('groupManagement').controller('GroupManagementController', ['$scope', '$stateParams', '$location', 'Authentication', 'GroupManagement',
	function($scope, $stateParams, $location, Authentication, GroupManagement) {
		$scope.authentication = Authentication;

		$scope.create = function() {
			debugger;
			var groupManagement = new GroupManagement({
				title: this.title
			});
			groupManagement.$save(function(response) {
				$location.path('/groupManagement/main' );
				$scope.title = '';
				$scope.content = '';
			}, function(errorResponse) {
				$scope.error = errorResponse.data.message;
			});
		};

		$scope.openDeletePopup = function() {
			alert("Deleted");
		};

		$scope.navigateToEditUser = function() {
			$location.path('/settings/profile');
		};

		$scope.initGroupManagementView = function(){
			$scope.groups = GroupManagement.query(function(groups) {
				//groups.forEach(function(group) {

				//});
			});
		};
	}
]);